// 提取不确定层数的Promise中的value类型的高级类型

type IsEqual<A, B> = (A extends B ? true : false) & (B extends A ? true : false);

// -------------------------------------------- Promise ----------------------------------------------------------------------

type tt = Promise<Promise<Promise<Record<string, any>>>>;

type GetDeepPromiseValueType<P extends Promise<unknown>> = P extends Promise<infer T> ? T extends Promise<unknown> ? GetDeepPromiseValueType<T> : T : P;
type GetDeepPromiseValueTypeR = GetDeepPromiseValueType<tt>;

// -------------------------------------------- 数组 ----------------------------------------------------------------------
// 实现数组的reverse反转
type GetReverse<Arr extends unknown[]> = Arr extends [infer First, ...infer Other] ? [...GetReverse<Other>, First] : Arr;
type GetReverseR = GetReverse<[1, 2, 4, 54]>

type GetUppercaseKey1<Obj extends object> = {
  [Key in keyof Obj as Key extends `${infer Prefix}${infer L}` ? `${Uppercase<Prefix>}${L}` : never] : Obj[Key];
}
type GetUppercaseKey1R = GetUppercaseKey1<{dfakjd:1, dlfajdj: 3}>

// 实现数组中是否包含某一项元素
type GetIncludes<Arr extends unknown[], ItemType> = Arr extends [infer Start, ...infer Last] ? Start extends ItemType ? true : GetIncludes<Last, ItemType> : false;
// Start extends ItemType 也可以替换成 IsEqual<Start, ItemType>
type GetIncludesR = GetIncludes<[1, 32, 4, 5], 1>
type GetIncludesR1 = GetIncludes<[1, 32, 4, 5], 99>

// 移除
type GetRemoveItem<Arr extends unknown[], ItemType, Result extends unknown[] = []> = Arr extends [infer First, ...infer Rest] ? IsEqual<First, ItemType> extends true ? GetRemoveItem<Rest, ItemType, Result> : GetRemoveItem<Rest, ItemType, [...Result, First]> : Result;
type GetRemoveItemR = GetRemoveItem<[1, 2,4 ,5 , 6], 4>



















